package sk.hackcraft.multibox.server;

import java.io.File;

import org.gstreamer.elements.PlayBin2;
import org.json.JSONObject;

import sk.hackcraft.multibox.util.IdentifiedCachedMap;

final public class Song extends PlayBin2 {
	static final public IdentifiedCachedMap<Song> all = new IdentifiedCachedMap<Song>();
	
	static public boolean isSong(File file) {
		return file.isFile();
	}
	
	final public File file;
	final public long id;
	final public String name;
	
	public Song(File file) {
		super(file.getAbsolutePath());
		setInputFile(file);
		
		name = file.getName();
		this.file = file;
		
		id = all.add(this);
	}
	
	public JSONObject toJSON() {
		JSONObject object = new JSONObject();
		
		object.put("name", name);
		object.put("id", id);
		
		return object;
	}
}
